﻿using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using COC.Character.Behave;

namespace COC.Character
{
    /// <summary>
    /// 基本模型
    /// </summary>
    [System.Serializable]
    public abstract class BaseModel : System.IComparable, IEqualityComparer
    {
        public long modelId { get; private set; }//模型的编号
        public string description { get; private set; }//模型简单说明 供UI页面展示如人物信息
        public string name { get; private set; }//模型的名称 如角色的名称 适合国际化
        public string assetUri { get; private set; }//prefab 地址
        public long referenceId
        {
            get { return referenceId; }
            private set { value = Int64.Parse(s: System.Guid.NewGuid().ToString()); }
        }//引用游戏实例对象的ID

        [System.Obsolete("instead of Character enum type,please using Character enumeration")]
        public MODEL_TYPE modelType { get; private set; }//模型类型
        public Character type;//角色模型类型
        [System.Obsolete]
        public int modelCategory { get; private set; } //模型的类别
        public bool isEnable { get; private set; } //模型是否启用
        [System.Obsolete]
        public int level { get; private set; }//模型的等级
        public bool hasScript { get; private set; }

        public string scriptName { get; private set; }//模型是否存在脚本
        public BasePlayValueModel prePlaySate { get; set; }//游戏第一次运行建筑的生命值，升级比率
        public BasePlayValueModel lastPlayState { get; set; }//与玩家互动后，建筑的生命值等
        public Dictionary<string, decimal> attributes = new Dictionary<string, decimal>(); //模型其他属性

        /// <summary>
        /// 
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public int CompareTo(object o)
        {
            BaseModel another = (BaseModel)o;
            if (this.modelType == another.modelType)
            {
                return 0;
            }
            if (this.modelType > another.modelType)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        public override bool Equals(object target)
        {
            return ((BaseModel)target).modelId == this.modelId;
        }

        public override int GetHashCode()
        {
            return this.modelId.GetHashCode();
        }

        public bool Equals(object x, object y)
        {
            return ((BaseModel)x).modelId == ((BaseModel)y).modelId;
        }

        public int GetHashCode(object obj)
        {
            BaseModel _obj = (BaseModel)obj;
            return _obj.modelId.GetHashCode();
        }
    }
}
/// <summary>
/// 基本模型类型
/// </summary>
public enum MODEL_TYPE
{
    HUMAN, /* 人物角色*/
    POSSESSION /*道具*/

}
/// <summary>
/// 人物模型类型
/// </summary>
public enum HUMAN_MODEL_TYPE
{
    HERO, /*英雄*/
    SOLIDER, /*军人*/
    MAGE/*法师*/
}
/// <summary>
/// 道具类型
/// </summary>
public enum POSSESSION_MODEL_TYPE
{

}
